package com.biconn.bigdata.spider.kafka.sender;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Controller;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

@Controller
public class Sender {
	@Autowired
	private KafkaTemplate<String, String> kafkatemplate;


    @ResponseBody
    @GetMapping("send")
    public String index()
    {
    	JSONObject obj = new JSONObject();
		obj.put("hospital_department", "老年病科, 心血管内科, 神经内科, 内分泌科, 呼吸内科, 普通内科, 肾病科, 消化内科, 急诊科, 骨科, 普外科, 心胸泌尿外科, 神经外科, 妇科, 儿科, 产科, 小儿营养保健科, 肿瘤科, 眼科, 干部病房, 重症医学科, 麻醉科, 超声科, 放疗科, 放射CT科, 中医科, 疼痛科, 功能检查科, 病理科, 传染科, 耳鼻喉, 口腔科, 皮肤科, 介入科");
		obj.put("hospital_link", "http://yiyuan.999ask.com/hospital/2656/");
    	ListenableFuture<SendResult<String, String>> RESULT = kafkatemplate.send("kafka.scrapy.question.and.answer", obj.toJSONString());
        System.out.println("发送消息成功");
    	return "success";
    }
}
